//菜单管理
//主控制器
interface Imenu extends ng.IScope {
    evaluat: number
    realName: string;

    jfry_order_csporder: boolean;
    jfry_inquiry_cspinquiry: boolean;
    jfry_external_delivery: boolean;
    jfry_client: boolean;
    jfry_client_manage: boolean;
    jfry_inquiry: boolean;
    jfry_inquiry_add: boolean;
    jfry_inquiry_accept: boolean;
    jfry_inquiry_receivable: boolean;
    jfry_inquiry_audit: boolean;
    jfry_inquiry_manage: boolean;
    jfry_order: boolean;
    jfry_order_add: boolean;
    jfry_order_accept: boolean;
    jfry_order_audit: boolean;
    jfry_order_register: boolean;
    jfry_order_manage: boolean;
    jfry_order_admin: boolean;
    jfry_cars: boolean;
    jfry_cars_manage: boolean;
    jfry_carrier_manage: boolean;
    jfry_fee: boolean;
    jfry_receipt_admin: boolean;
    jfry_fee_audit: boolean;
    jfry_cost_recoverable: boolean;
    jfry_settle_admin: boolean;
    jfry_payment_admin: boolean;
    jfry_payable_admin: boolean;
    jfry_receivable: boolean;
    jfry_receivable_settle: boolean;
    jfry_receivable_bill: boolean;
    jfry_receivable_admin: boolean;
    jfry_receivable_census: boolean;
    jfry_receivable_accountreturnanalysis: boolean;
    jfry_excel: boolean;
    jfry_fee_excel: boolean;
    jfry_receivable_excel: boolean;
    jfry_profit_excel: boolean;
    jfry_custom_excel: boolean;
    jfry_capacity_excel: boolean;
    jfry_business_excel: boolean;
    jfry_dispatch_profit: boolean;
    jfry_set_up: boolean;
    jfry_authorization_type: boolean;
    jfry_authorization: boolean;
    jfry_authorization_manage: boolean;
    jfry_department_manage: boolean;
    jfry_employee_manage: boolean;
    jfry_logistics_userinfo_edit: boolean;
    jfry_user_manage: boolean;
    jfry_usergroup_manage: boolean;
    jfry_logistics_manage: boolean;
    jfry_report: boolean;
    jfry_Evaluate: boolean;
    jfry_Evaluate_manage: boolean;
    jfry_ReverseEvaluate_manage: boolean;
    jfry_report_export: boolean;
    jfry_report_workreport: boolean;
    jfry_operation: boolean;
    jfry_operation_list: boolean;
    jfry_location_list: boolean;
    jfry_opinion__manage: boolean;
    jfry_opinion__log: boolean;
    commissT: boolean;
    /**判断申领密码权限 */
    isSclick(): void;
    /**修改用户密码 */
    isauthEdUser: boolean;
    /**修改申领密码 */
    isauthNUser: boolean;
    /**
    * 是否重复
    */
    ifArrVal: (arr, obj) => void;
    /** */
    snapArr: Array<string>;
    /**nums */
    nums: number;
    /**空 */
    EnumC: number;



    /**
     * 意见反馈模态框内信息(标题，意见内容)
     */
    modalTitle: string;
    modalContent: string;
    //提交按钮事件
    clickFeedback(): void;//确定按钮事件
    /**
     * 意见反馈图片的上传组件
     */
    attachmentUploader: any;
    //意见反馈弹窗事件
    addFeedback(): void
    //更新内容
    updateContentArr: string;

    updateCont:Array<any>

}


interface ImainRootScope extends ng.IRootScopeService {
    messageTotal: string;
    /**未读消息 */
    unReadList:Array<MessageListItemResponse>; //unReda[];
    /**注销 */
    logout(): void;
    /**报表导出消息 */
    excelExportList: excelList[];
    /**子节点数 */
    EnumChildren: number;
    /**下载报表 */
    downloadExcel(Path: string, skey: string): void;
    /**取消下载 */
    selectCancel(skey: string, ckey: string, IsCancel: boolean, IsTrue: boolean, ProgressValue: number): void;


    tcr_startAddress: string;
    tcr_endAddress: string;
    tcr_startCityCode: string;
    tcr_endCityCode: string;

    /**
     * 用户头像
     */
    headPath: string;



}
/**未读消息野狗数据 */
interface unReda {
    Content: string;
    InvalidTime: string;
    Time: string;
    Type: number;
    key?: string;
    isRead?: number;
}
/**报表导出消息野狗数据 */
interface excelList {
   
    time?: string;
    /** */
    ckey?: string;
    /** */
    skey?: string;
    /**中文文件名称 */
    CnFileName: string;
    /**是否成功 */
    IsTrue: boolean;
    /**文件下载路径 */
    Path?: string;
    /**下载进度 */
    ProgressValue: number;
    /**是否取消 */
    IsCancel?: boolean;

    // 点击导出表报后，临时的假信息，仅用于显示
    IsFakeInfo?: boolean
}

class menuCtrl {

    /**
     * 消息
     */
    messageStorage: string;
    /**评价存储 */
    evaluatStorage: string;
    /**报表导出存储 */
    excelStorage: string;
    messRef: any;
    /**野狗评价消息 */
    evaluatRef: any;
    /**野狗报表导出消息 */
    excelRef: any;
    /**野狗地址 */
    wilddogUrl: string;
    /**子节点数 */
    numChildren: number;
    /** */
    ExnumChildren: number;
    /**菜单列表 */
    menuList: string[] = [];
    /**菜单子列表 */
    menuChilderList: string[] = [];
    /**登录数据 */
    loginData: {
        /**编号 */
        id: string;
        /**真实姓名 */
        realName: string;
        /**用户组 */
        userGroup: string;
        /**专员类型 */
        commissionerType: string[];
    };

    //意见反馈的图片
    uploaderList: Array<attachmentList>;

    contentUpdate:string;



    //判定首页更新内容的展示与否
    // loginId:any;
    //智运通版本号
    // versionTms="V18-0315";
    
    constructor(private $scope: Imenu, private wilddogService: wilddogService, private $rootScope: ImainRootScope, private routeService: routeService, private toaster: any, private $state: ng.ui.IStateService,
        private menuService: IMenuService, private $timeout: ng.ITimeoutService, private loginService: ILoginService, private RongIMSDKServer: any,
        private authorizationService: IAuthorizationService, private commonService: ICommonService, private $ngBootbox: BootboxService,
        private operationService: IOperationService,private messageService:IMessageService) {
        this.$rootScope.unReadList = [];
        this.$rootScope.excelExportList = [];
        this.$rootScope.EnumChildren = 0;

        this.$scope.snapArr = [];

        this.uploaderList = [];

        //野狗
        // this.wilddogUrl = this.routeService.getWilddogUrl() ;  //"https://wd6091211065qhjgok.wilddogio.com/"; // 

        this.init();
    }

    init(): void {
        this.loginData = JSON.parse(window.localStorage.getItem("loginData"));
        //this.getMenu();
        this.getMenuFromLoginInfo()
        this.$scope.isSclick = this.isSclick;
        let loginData = JSON.parse(window.localStorage.getItem("loginData"));
        if (loginData.commissionerType.indexOf('调度专员') > -1) {
            this.$scope.commissT = true;
        } else {
            this.$scope.commissT = false;
        }

        // const zhengshifu = new Wilddog('https://tmsystem.wilddogio.com/9/2');

        // zhengshifu.remove();

        //刷新下获取未读消息列表
        this.messageService.getList(this.loginData.id,false,0,5).then((res)=>{
            console.log('resNoRead2',res.data);
            this.$rootScope.unReadList = res.data.data;
            // this.$rootScope.messageTotal = res.data.total.toString()
        })



        //页面缩放弹窗的样式
        var t = this.iscal(), i = 512, n = 292;
        var o = 100 * i / Number(t),
            a = 100 * n / Number(t);
        $('#zoomModal').css({
            'width': o + 'px',
            'height': a + 'px',
            'margin-left': -o / 2 + 'px',
            'margin-top': -a / 2 + 'px'
        })
        //初始页面缩放弹框状态
        if (window.localStorage.getItem('zoomNo')) {
            $('#zoomModal').modal('hide');
            $('#updateContent').show();
            // return;
        }else if(window.devicePixelRatio!=1){
            $('#zoomModal').modal('show');
            $('#updateContent').hide();
        }

        if (loginData) {
            this.$scope.realName = loginData.realName;

            //页面缩放事件
            window.onresize = () => {
                var warn = window.localStorage.getItem('zoomNo');
                if (warn) {
                    $('#zoomModal').modal('hide');
                    $('#updateContent').show();
                    // return;
                }else if(window.devicePixelRatio!=1){
                    $('#zoomModal').modal('show');
                    $('#updateContent').hide();
                    var t=this.iscal(),i=512,n=292;
                    var o= 100*i / Number(t),
                    a=100*n / Number(t);
                    $('#zoomModal').css({
                        'width': o + 'px',
                        'height': a + 'px',
                        'margin-left': -o / 2 + 'px',
                        'margin-top': -a / 2 + 'px'
                    })
                }else{
                    $('#zoomModal').modal('hide');
                    $('#updateContent').show();
                }
            }

        }
        //页面缩放提示窗口的“不再提醒”事件
        $('.zoomButt').on("click", function () {
            window.localStorage.setItem('zoomNo', 'neverNotify');
            $('#zoomModal').modal('hide');
        })
        //页面缩放提示窗口的“关闭”事件
        $('.zoomClose').on("click", function () {
            $('#zoomModal').modal('hide');
        })

        //更新弹框内容
        this.updateContent();
    
        
        //关闭展示内容
        // this.$scope.$on('hideNewContentModal',()=>{
        //     //加载页面的时间
        //     setTimeout(function() {
        //         $("#updateContent").hide();
        //         // $("#updateContent").css({display:'none'});
        //     }, 200);
        // })
        
        // //3.17修改提示框
        // //获取版本号
        // this.loginService.getVersionInfo().then((res)=>{
        //     // console.log('loginAfter',res);
        //     if(res.data.version && res.data.version=="-"){
        //         $("#updateContent").animate({bottom: '0px'},1000);
        //     }
        // })

        //更新内容的上下滑动
        var f=0;
        $('#updateCont_img').on("click",()=>{
            if(f==1){
                $('.updateCont_tit a').css("background",'url(../src/img/upArrow.png) center  no-repeat');
                $("#updateContent").animate({bottom: '-151px'},1000);
                f=0;
            }else{
                $('.updateCont_tit a').css("background",'url(../src/img/downArrow.png) center  no-repeat');
                $("#updateContent").animate({bottom: '0px'},1000);
                f=1;
            }
            
        })
 

        this.$timeout(() => {
            this.messageStorage = window.localStorage.getItem("refEvaluateShipOrder");
            this.evaluatStorage = window.localStorage.getItem("refEvaluate");

            if (this.messageStorage) {
                // this.messRef = new Wilddog(this.messageStorage);
                this.$scope.realName = this.loginData.realName;
                /**
                 * 获取消息总数
                 */
                // this.messRef.orderByChild("isRead").equalTo(0).on("value", (snapshot) => {
                //     // console.log('total',snapshot.numChildren())                                        
                //     this.$rootScope.messageTotal = snapshot.numChildren();
                // });
                // //获取子节点个数
                // this.messRef.once("value", (snapshot) => {
                //     // this.numChildren = snapshot.numChildren();
                //     // console.log('this.numChildren',this.numChildren)
                    // this.addMessageTotal();
                // });
                this.addMessageTotal();
                this.getMessageInfo();
                this.getUnread();
                this.$rootScope.logout = this.logout;
            };
            if (this.evaluatStorage) {
                // this.evaluatRef = new Wilddog(this.evaluatStorage);
                // this.evaluatRef.on("value", (snapshot) => {
                //     snapshot.numChildren() == 0 ? this.$scope.evaluat = null : this.$scope.evaluat = snapshot.numChildren();
                // });
            }
        })



        //右下角的二维码和意见反馈
        var flag = 0, flags = 0;
        $('#rightArrow').on("click", function () {
            if (flag == 1) {
                $("#floatDivBoxs .modal-erweima").animate({ left: '98px' }, 300);
                $("#floatDivBoxs .modal-feedBack").animate({ left: '47px' }, 300);
                $(this).css('background', 'url(../src/img/menu-right2.png) #141E27 center  no-repeat');
                flag = 0;
            } else {
                $('.erweimaShow').hide();
                $('.modal-erweima').css('background', 'url(../src/img/menu-erweima.png) #141E27 center  no-repeat');
                flags = 0;
                $("#floatDivBoxs .modal-erweima").animate({ left: '149px' }, 300);
                $("#floatDivBoxs .modal-feedBack").animate({ left: '149px' }, 300);
                $(this).css('background', 'url(../src/img/menu-left.png) #86A0B1 center  no-repeat');
                flag = 1;
            }
        });
        //二维码展示
        $('.modal-erweima').on("click", function () {
            if (flags == 1) {
                $('.modal-erweima').css('background', 'url(../src/img/menu-erweima.png) #141E27 center  no-repeat');
                $('.erweimaShow').hide()
                flags = 0;
            } else {
                $('.modal-erweima').css('background', 'url(../src/img/menu-erweima2.png) #fff center  no-repeat');
                $('.erweimaShow').show()
                flags = 1;
            }
        })

        //摩模态框打开或关闭时，改变背景图片
        // this.$scope.addFeedback= this.showAddFeedback;
        $('#opinionFeed').on('show.bs.modal', function () {
            $('.modal-feedBack').css('background', 'url(../src/img/menu-modalFeedBack2.png) #fff center  no-repeat');
        })
        $('#opinionFeed').on('hide.bs.modal', function () {
            $('.modal-feedBack').css('background', 'url(../src/img/menu-modalFeedBack.png) #141E27 center  no-repeat');
        })

        //意见反馈模态框中的信息






    }

    //更新内容提示
    updateContent=()=>{
        this.contentUpdate = '1、修改子模块提醒数字显示、更新说明框等与野狗服务有关功能；2、客服在发货单登记删除应收费用逻辑修改为只可删除退回办理应收费用；3、在付款方式选项中增加：苏通卡。'
        
        //获取版本号
        this.loginService.getVersionInfo().then((res)=>{
            //已经添加一次版本号了，下次登录就不需要再添加了；当没有版本号时候，添加版本号
            if(res.data.version && res.data.version=="4"){
                this.contentUpdate = res.data.versionSummary;
            }else{
                //添加版本号
                this.loginService.addVersionInfo('1','4',this.contentUpdate.toString()).then(res=>{
                })
                this.contentUpdate=this.contentUpdate
            }
            this.$scope.updateCont = this.contentUpdate.split("；")
        })
        //展开弹框内容
        // setTimeout(function () {
        //     $("#updateContent").animate({ bottom: '0px' }, 1000);
        // }, 200);
    }

    //页面缩放
    iscal = () => {
        var e = 0
            , t = window.screen;
        return void 0 !== window.devicePixelRatio ? e = window.devicePixelRatio : navigator.userAgent.toLowerCase().indexOf("msie") ? t.deviceXDPI && t.logicalXDPI && (e = t.deviceXDPI / t.logicalXDPI) : void 0 !== window.outerWidth && void 0 !== window.innerWidth && (e = window.outerWidth / window.innerWidth),
            e && (e = Math.round(100 * e)),
            99 !== e && 101 !== e || (e = 100),
            e
    }



    /**判断申领密码权限 */
    isSclick = () => {
        this.$scope.isauthEdUser = false;
        this.$scope.isauthNUser = false;
        /**修改用户密码 */
        this.authorizationService.auth("BDB4B5A9DB860CFDA76456CF18DA71C7BF42DBD028704BD2CA3FFD18A519F10A").then((res) => {
            this.$scope.isauthEdUser = res.data.extData;
            console.log(res.data);
        }, (rej) => { });

        /**修改用户密码 */
        this.authorizationService.auth("BDB4B5A9DB860CFDA76456CF18DA71C725310928B00E989C5CC4239EF061A153").then((res) => {
            this.$scope.isauthNUser = res.data.extData;
        }, (rej) => { });

    }
    /**
     * 支付消息
     */
    getMessageInfo(): void {
        if (!this.messageStorage) { return };
        var ref = new Wilddog(this.messageStorage);
    }
    /**
     * 获取消息总数
     */
    getMessageTotal(): void {
        this.messageService.getNoReadSystemNotifyCount(this.loginData.id).then(res=>{
            // console.log('当',res.data.extData)
            this.$rootScope.messageTotal = res.data.extData
        })
    }

    /**
     * 添加未读消息数
     */
    addMessageTotal = () => {
        var num = 0;
        // this.messRef.on("child_added", (snapshot) => {
        //     num++;
        //     if (num > this.numChildren) {
        //         if (snapshot.val().Content) {
        //             //消息通知
        //             this.$timeout(() => { this.toaster.pop("success", "消息通知", snapshot.val().Content); });
        //             //添加未读状态
        //             if (!snapshot.val().isRead) {
        //                 var childRef = new Wilddog(this.wilddogUrl + JSON.parse(window.localStorage.getItem("loginData")).id + "/" + 1 + "/" + "0/" + snapshot.key());
        //                 childRef.update({
        //                     isRead: 0
        //                 });
        //                 // childRef.set({
        //                 //     isRead: 0
        //                 // });
        //             }
        //             if (snapshot.val().Type == 0) {//监听广播电子合同消息
        //                 this.$rootScope.$broadcast('WildDog:Econtract');
        //             }
        //         }
        //         if (!snapshot.val().Content) {
        //             this.messRef.child(snapshot.key()).remove();
        //         }
        //     }
        //     this.getMessageTotal();
        // });

        this.$rootScope.$on('toaster', (e, info) => {
            const content = info.Content;
            if (!this.$rootScope.unReadList) {
                this.$rootScope.unReadList = []
            }
            // console.log('toaster_msg', content)
            num++;
            // if (num > this.numChildren) {
            if (content && info.NotifyType == 0) {
                //消息通知
                this.$timeout(() => { this.toaster.pop("success", "消息通知", content.Content); });
                // this.$rootScope.unReadList.push(content);

                if (content.Type == 0) {//监听广播电子合同消息
                    this.$rootScope.$broadcast('WildDog:Econtract');
                }
                
            }

           
            //刷新下获取未读消息数
            // this.messageService.getNoReadSystemNotifyCount(this.notifier).then(res=>{
            //     // console.log('当')
            //     this.$rootScope.messageTotal = res.data.extData
            // })
            //刷新下获取未读消息列表
            this.messageService.getList(this.loginData.id,false,0,5).then((res)=>{
                console.log('resNoRead1',res.data);
                this.$rootScope.unReadList = res.data.data;
                window.localStorage.setItem('unReadList', JSON.stringify(this.$rootScope.unReadList))
                // this.$rootScope.messageTotal = res.data.total.toString()
            })

            this.getMessageTotal();
        })
    }



    /**
     * 获取未读消息
     */
    getUnread = () => {
        

        // this.messRef.orderByChild("isRead").equalTo(0).limitToFirst(99).on("value", (snapshot) => {
        //     if (snapshot.val()) {
        //         this.$rootScope.unReadList = [];
        //         snapshot.forEach((snap) => {
        //             if (snap.val().Content) {
        //                 this.$rootScope.unReadList.push({
        //                     Content: snap.val().Content,
        //                     InvalidTime: snap.val().InvalidTime,
        //                     Time: snap.val().Time,
        //                     Type: snap.val().Type,
        //                     key: snap.key()
        //                 });
        //             } else {
        //                 this.messRef.child(snap.key()).remove();
        //             }
        //         })
        //     }
        //     // this.$rootScope.$apply(()=>{this.$rootScope.unReadList});
        // });
        this.$rootScope.unReadList = JSON.parse(window.localStorage.getItem('unReadList'))
        this.getMessageTotal();
    }

    /**
     * 注销
     */
    logout = () => {
        // this.evaluatRef.off("value");
        // this.messRef.off("value");
        // this.messRef.off("child_added");
        localStorage.clear();
        // bughd('removeUser');
        this.$state.go('login.in');
        this.RongIMSDKServer.disconnect();
        // if (this.$scope.commissT) {
        //     this.RongIMSDKServer.disconnect();
        // }
    }

    /**
     * 获取权限
     */
    getMenu = () => {
        this.menuService.getMenu().then((res) => {
            if (!res.data.data || res.data.data.length < 1 || !res.data.data.forEach) { return };
            res.data.data.forEach((item, index) => {
                this.menuList.push(item.name)
                item.menu_child.forEach((itemC, index) => {
                    this.menuChilderList.push(itemC.name)
                });
            });
            let sc = this.$scope;

            sc.jfry_external_delivery = this.menuChilderList.indexOf('jfry_external_delivery') == -1;

            sc.jfry_client = this.menuList.indexOf('jfry_client') > -1;
            sc.jfry_client_manage = this.menuChilderList.indexOf('jfry_client_manage') > -1;
            sc.jfry_client_manage = this.menuChilderList.indexOf('jfry_client_manage') > -1;

            sc.jfry_inquiry = this.menuList.indexOf('jfry_inquiry') > -1;
            sc.jfry_inquiry_cspinquiry = this.menuChilderList.indexOf('jfry_inquiry_cspinquiry') > -1;
            sc.jfry_inquiry_add = this.menuChilderList.indexOf('jfry_inquiry_add') > -1;
            sc.jfry_inquiry_accept = this.menuChilderList.indexOf('jfry_inquiry_accept') > -1;
            sc.jfry_inquiry_receivable = this.menuChilderList.indexOf('jfry_inquiry_receivable') > -1;
            sc.jfry_inquiry_audit = this.menuChilderList.indexOf('jfry_inquiry_audit') > -1;
            sc.jfry_inquiry_manage = this.menuChilderList.indexOf('jfry_inquiry_manage') > -1;

            sc.jfry_order = this.menuList.indexOf('jfry_order') > -1;
            sc.jfry_order_csporder = this.menuChilderList.indexOf('jfry_order_csporder') > -1;
            sc.jfry_order_add = this.menuChilderList.indexOf('jfry_order_add') > -1;
            sc.jfry_order_accept = this.menuChilderList.indexOf('jfry_order_accept') > -1;
            sc.jfry_order_audit = this.menuChilderList.indexOf('jfry_order_audit') > -1;
            sc.jfry_order_register = this.menuChilderList.indexOf('jfry_order_register') > -1;
            sc.jfry_order_manage = this.menuChilderList.indexOf('jfry_order_manage') > -1;
            sc.jfry_order_admin = this.menuChilderList.indexOf('jfry_order_admin') > -1;

            sc.jfry_cars = this.menuList.indexOf('jfry_cars') > -1;
            sc.jfry_cars_manage = this.menuChilderList.indexOf('jfry_cars_manage') > -1;
            sc.jfry_carrier_manage = this.menuChilderList.indexOf('jfry_carrier_manage') > -1;

            sc.jfry_fee = this.menuList.indexOf('jfry_fee') > -1;
            sc.jfry_receipt_admin = this.menuChilderList.indexOf('jfry_receipt_admin') > -1;
            sc.jfry_fee_audit = this.menuChilderList.indexOf('jfry_fee_audit') > -1;
            sc.jfry_cost_recoverable = this.menuChilderList.indexOf('jfry_cost_recoverable') > -1;
            sc.jfry_settle_admin = this.menuChilderList.indexOf('jfry_settle_admin') > -1;
            sc.jfry_payment_admin = this.menuChilderList.indexOf('jfry_payment_admin') > -1;
            sc.jfry_payable_admin = this.menuChilderList.indexOf('jfry_payable_admin') > -1;

            sc.jfry_receivable = this.menuList.indexOf('jfry_receivable') > -1;
            sc.jfry_receivable_settle = this.menuChilderList.indexOf('jfry_receivable_settle') > -1;
            sc.jfry_receivable_bill = this.menuChilderList.indexOf('jfry_receivable_bill') > -1;
            sc.jfry_receivable_admin = this.menuChilderList.indexOf('jfry_receivable_admin') > -1;
            sc.jfry_receivable_census = this.menuChilderList.indexOf('jfry_receivable_census') > -1;
            sc.jfry_receivable_accountreturnanalysis = this.menuChilderList.indexOf('jfry_receivable_accountreturnanalysis') > -1;

            sc.jfry_excel = this.menuList.indexOf('jfry_excel') > -1;
            sc.jfry_fee_excel = this.menuChilderList.indexOf('jfry_fee_excel') > -1;
            sc.jfry_receivable_excel = this.menuChilderList.indexOf('jfry_receivable_excel') > -1;
            sc.jfry_profit_excel = this.menuChilderList.indexOf('jfry_profit_excel') > -1;
            sc.jfry_custom_excel = this.menuChilderList.indexOf('jfry_custom_excel') > -1;
            sc.jfry_capacity_excel = this.menuChilderList.indexOf('jfry_capacity_excel') > -1;
            sc.jfry_business_excel = this.menuChilderList.indexOf('jfry_business_excel') > -1;
            sc.jfry_dispatch_profit = this.menuChilderList.indexOf('jfry_dispatch_profit') > -1;

            sc.jfry_set_up = this.menuList.indexOf('jfry_set_up') > -1;
            sc.jfry_authorization_type = this.menuChilderList.indexOf('jfry_authorization_type') > -1;
            sc.jfry_authorization = this.menuChilderList.indexOf('jfry_authorization') > -1;
            sc.jfry_authorization_manage = this.menuChilderList.indexOf('jfry_authorization_manage') > -1;
            sc.jfry_department_manage = this.menuChilderList.indexOf('jfry_department_manage') > -1;
            sc.jfry_employee_manage = this.menuChilderList.indexOf('jfry_employee_manage') > -1;
            sc.jfry_logistics_userinfo_edit = this.menuChilderList.indexOf('jfry_logistics_userinfo_edit') > -1;

            sc.jfry_user_manage = this.menuChilderList.indexOf('jfry_user_manage') > -1;
            sc.jfry_usergroup_manage = this.menuChilderList.indexOf('jfry_usergroup_manage') > -1;
            sc.jfry_logistics_manage = this.menuChilderList.indexOf('jfry_logistics_manage') > -1;

            sc.jfry_report = this.menuList.indexOf('jfry_report') > -1;
            sc.jfry_report_export = this.menuChilderList.indexOf('jfry_report_export') > -1;
            sc.jfry_report_workreport = this.menuChilderList.indexOf('jfry_report_workreport') > -1;

            //评价的权限  通过menuService获取权限的时候，评价默认是都显示的，故而这里默认为true
            sc.jfry_Evaluate_manage = true
            sc.jfry_Evaluate = sc.jfry_Evaluate_manage

            sc.jfry_operation = this.menuList.indexOf('jfry_operation') > -1;
            sc.jfry_operation_list = this.menuChilderList.indexOf('jfry_operation_list') > -1;
            sc.jfry_location_list = this.menuChilderList.indexOf('jfry_location_list') > -1;
            sc.jfry_opinion__manage = this.menuChilderList.indexOf('jfry_opinion__manage') > -1;
            sc.jfry_opinion__log = this.menuChilderList.indexOf('jfry_opinion__log') > -1;

        });
    }

    /**
     * 从登陆信息获取权限
     * 以前权限是从menuService里调用接口获取的，权限改版后，直接从登陆接口返回二级菜单的tag，由此判断权限并显示相应内容
     */
    getMenuFromLoginInfo = () => {

        var menuInfo = localStorage.getItem('secAuthorizationTypeTag');

        if (!menuInfo) {
            return;
        }
        this.menuChilderList = menuInfo.split('+');

        let sc = this.$scope;

        sc.jfry_external_delivery = this.menuChilderList.indexOf('jfry_external_delivery') == -1;

        // sc.jfry_client =this.menuList.indexOf('jfry_client') > -1;
        sc.jfry_client_manage = this.menuChilderList.indexOf('jfry_client_manage') > -1;
        sc.jfry_client_manage = this.menuChilderList.indexOf('jfry_client_manage') > -1;
        sc.jfry_client = sc.jfry_client_manage;

        // sc.jfry_inquiry =this.menuList.indexOf('jfry_inquiry') > -1;
        sc.jfry_inquiry_cspinquiry = this.menuChilderList.indexOf('jfry_inquiry_cspinquiry') > -1;
        sc.jfry_inquiry_add = this.menuChilderList.indexOf('jfry_inquiry_add') > -1;
        sc.jfry_inquiry_accept = this.menuChilderList.indexOf('jfry_inquiry_accept') > -1;
        sc.jfry_inquiry_receivable = this.menuChilderList.indexOf('jfry_inquiry_receivable') > -1;
        sc.jfry_inquiry_audit = this.menuChilderList.indexOf('jfry_inquiry_audit') > -1;
        sc.jfry_inquiry_manage = this.menuChilderList.indexOf('jfry_inquiry_manage') > -1;
        sc.jfry_inquiry = sc.jfry_inquiry_cspinquiry || sc.jfry_inquiry_add || sc.jfry_inquiry_add || sc.jfry_inquiry_receivable || sc.jfry_inquiry_audit || sc.jfry_inquiry_manage


        // sc.jfry_order =this.menuList.indexOf('jfry_order') > -1;
        sc.jfry_order_csporder = this.menuChilderList.indexOf('jfry_order_csporder') > -1;
        sc.jfry_order_add = this.menuChilderList.indexOf('jfry_order_add') > -1;
        sc.jfry_order_accept = this.menuChilderList.indexOf('jfry_order_accept') > -1;
        sc.jfry_order_audit = this.menuChilderList.indexOf('jfry_order_audit') > -1;
        sc.jfry_order_register = this.menuChilderList.indexOf('jfry_order_register') > -1;
        sc.jfry_order_manage = this.menuChilderList.indexOf('jfry_order_manage') > -1;
        sc.jfry_order_admin = this.menuChilderList.indexOf('jfry_order_admin') > -1;
        sc.jfry_order = sc.jfry_order_csporder || sc.jfry_order_add || sc.jfry_order_accept || sc.jfry_order_audit || sc.jfry_order_register || sc.jfry_order_manage || sc.jfry_order_admin


        // sc.jfry_cars =this.menuList.indexOf('jfry_cars') > -1;
        sc.jfry_cars_manage = this.menuChilderList.indexOf('jfry_cars_manage') > -1;
        sc.jfry_carrier_manage = this.menuChilderList.indexOf('jfry_carrier_manage') > -1;
        sc.jfry_cars = sc.jfry_cars_manage || sc.jfry_carrier_manage


        // sc.jfry_fee =this.menuList.indexOf('jfry_fee') > -1;
        sc.jfry_receipt_admin = this.menuChilderList.indexOf('jfry_receipt_admin') > -1;
        sc.jfry_fee_audit = this.menuChilderList.indexOf('jfry_fee_audit') > -1;
        sc.jfry_cost_recoverable = this.menuChilderList.indexOf('jfry_cost_recoverable') > -1;
        sc.jfry_settle_admin = this.menuChilderList.indexOf('jfry_settle_admin') > -1;
        sc.jfry_payment_admin = this.menuChilderList.indexOf('jfry_payment_admin') > -1;
        sc.jfry_payable_admin = this.menuChilderList.indexOf('jfry_payable_admin') > -1;
        sc.jfry_fee = sc.jfry_receipt_admin || sc.jfry_fee_audit || sc.jfry_cost_recoverable || sc.jfry_settle_admin || sc.jfry_payment_admin || sc.jfry_payable_admin


        // sc.jfry_receivable =this.menuList.indexOf('jfry_receivable') > -1;
        sc.jfry_receivable_settle = this.menuChilderList.indexOf('jfry_receivable_settle') > -1;
        sc.jfry_receivable_bill = this.menuChilderList.indexOf('jfry_receivable_bill') > -1;
        sc.jfry_receivable_admin = this.menuChilderList.indexOf('jfry_receivable_admin') > -1;
        sc.jfry_receivable_census = this.menuChilderList.indexOf('jfry_receivable_census') > -1;
        sc.jfry_receivable_accountreturnanalysis = this.menuChilderList.indexOf('jfry_receivable_accountreturnanalysis') > -1;
        sc.jfry_receivable = sc.jfry_receivable_settle || sc.jfry_receivable_bill || sc.jfry_receivable_admin || sc.jfry_receivable_census || sc.jfry_receivable_accountreturnanalysis


        // sc.jfry_excel =this.menuList.indexOf('jfry_excel') > -1;
        sc.jfry_fee_excel = this.menuChilderList.indexOf('jfry_fee_excel') > -1;
        sc.jfry_receivable_excel = this.menuChilderList.indexOf('jfry_receivable_excel') > -1;
        sc.jfry_profit_excel = this.menuChilderList.indexOf('jfry_profit_excel') > -1;
        sc.jfry_custom_excel = this.menuChilderList.indexOf('jfry_custom_excel') > -1;
        sc.jfry_capacity_excel = this.menuChilderList.indexOf('jfry_capacity_excel') > -1;
        sc.jfry_business_excel = this.menuChilderList.indexOf('jfry_business_excel') > -1;
        sc.jfry_dispatch_profit = this.menuChilderList.indexOf('jfry_dispatch_profit') > -1;
        sc.jfry_excel = sc.jfry_fee_excel || sc.jfry_receivable_excel || sc.jfry_profit_excel || sc.jfry_custom_excel || sc.jfry_capacity_excel || sc.jfry_business_excel || sc.jfry_dispatch_profit


        // sc.jfry_set_up =this.menuList.indexOf('jfry_set_up') > -1;
        sc.jfry_authorization_type = this.menuChilderList.indexOf('jfry_authorization_type') > -1;
        sc.jfry_authorization = this.menuChilderList.indexOf('jfry_authorization') > -1;
        sc.jfry_authorization_manage = this.menuChilderList.indexOf('jfry_authorization_manage') > -1;
        sc.jfry_department_manage = this.menuChilderList.indexOf('jfry_department_manage') > -1;
        sc.jfry_employee_manage = this.menuChilderList.indexOf('jfry_employee_manage') > -1;
        sc.jfry_logistics_userinfo_edit = this.menuChilderList.indexOf('jfry_logistics_userinfo_edit') > -1;

        sc.jfry_user_manage = this.menuChilderList.indexOf('jfry_user_manage') > -1;
        sc.jfry_usergroup_manage = this.menuChilderList.indexOf('jfry_usergroup_manage') > -1;
        sc.jfry_logistics_manage = this.menuChilderList.indexOf('jfry_logistics_manage') > -1;
        sc.jfry_set_up = sc.jfry_authorization_type || sc.jfry_authorization || sc.jfry_authorization_manage || sc.jfry_department_manage || sc.jfry_employee_manage || sc.jfry_logistics_userinfo_edit || sc.jfry_user_manage || sc.jfry_usergroup_manage || sc.jfry_logistics_manage


        // sc.jfry_report =this.menuList.indexOf('jfry_report') > -1;
        sc.jfry_report_export = this.menuChilderList.indexOf('jfry_report_export') > -1;
        sc.jfry_report_workreport = this.menuChilderList.indexOf('jfry_report_workreport') > -1;
        sc.jfry_report = sc.jfry_report_export || sc.jfry_report_workreport

        sc.jfry_Evaluate_manage = this.menuChilderList.indexOf('jfry_Evaluate_manage') > -1;
        sc.jfry_ReverseEvaluate_manage = this.menuChilderList.indexOf('jfry_ReverseEvaluate_manage') > -1;
        sc.jfry_Evaluate = sc.jfry_Evaluate_manage || sc.jfry_ReverseEvaluate_manage;

        sc.jfry_operation_list = this.menuChilderList.indexOf('jfry_operation_list') > -1;
        sc.jfry_location_list = this.menuChilderList.indexOf('jfry_location_list') > -1;
        sc.jfry_opinion__manage = this.menuChilderList.indexOf('jfry_opinion__manage') > -1;
        sc.jfry_opinion__log = this.menuChilderList.indexOf('jfry_opinion__log') > -1;
        sc.jfry_operation = sc.jfry_operation_list || sc.jfry_location_list || sc.jfry_opinion__manage || sc.jfry_opinion__log;

    }




}
angular.module("tms").controller("menuCtrl", ["$scope", "wilddogService", "$rootScope", "routeService", 'toaster', '$state',
    'menuService', '$timeout', "loginService", "RongIMSDKServer", "authorizationService",
    "commonService", "$ngBootbox", "operationService","messageService", menuCtrl])
